Object.defineProperty(exports, "__esModule", {
    value: true
});

var _extends = Object.assign || function(target) {
    for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i];
        for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
                target[key] = source[key];
            }
        }
    }
    return target;
};

var _createClass = function() {
    function defineProperties(target, props) {
        for (var i = 0; i < props.length; i++) {
            var descriptor = props[i];
            descriptor.enumerable = descriptor.enumerable || false;
            descriptor.configurable = true;
            if ("value" in descriptor) descriptor.writable = true;
            Object.defineProperty(target, descriptor.key, descriptor);
        }
    }
    return function(Constructor, protoProps, staticProps) {
        if (protoProps) defineProperties(Constructor.prototype, protoProps);
        if (staticProps) defineProperties(Constructor, staticProps);
        return Constructor;
    };
}();

function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
    }
}

var MyModal = function() {
    function MyModal(context) {
        _classCallCheck(this, MyModal);
        this.context = context;
        this._defaultConfig = {
            isModalShow: false,
            isShowFooter: true,
            modalContent: {
                beforeTitle: "",
                afterTitle: "",
                strongTitle: "",
                title: "",
                content: "",
                beforeContent: "",
                strongContent: "",
                afterContent: "",
                footer: {
                    confirmText: "确认",
                    cancelText: "取消"
                }
            },
            contentWrapHeight: 336,
            isShowSlot: false,
            slotName: "defaultSlot"
        };
        this.context.setData(this._defaultConfig);
    }
    // 显示弹窗
        _createClass(MyModal, [ {
        key: "show",
        value: function show(options) {
            this.context.setData({
                isModalShow: true,
                isShowFooter: typeof options.isShowFooter === "undefined" ? this._defaultConfig.isShowFooter : !!options.isShowFooter,
                modalContent: _extends({}, this._defaultConfig.modalContent, options.modalContent),
                contentWrapHeight: options.contentWrapHeight || this._defaultConfig.contentWrapHeight,
                isShowSlot: typeof options.isShowSlot === "undefined" ? this._defaultConfig.isShowSlot : !!options.isShowSlot,
                slotName: options.slotName || this._defaultConfig.slotName
            });
            var it = this;
            it.context.onModalConfirm = function() {
                // 隐藏Modal
                it.hide();
                // 执行相关事件
                                if (typeof options.onModalConfirm === "function") {
                    options.onModalConfirm.call(it.context);
                }
            };
            it.context.onModalCancel = function() {
                it.hide();
                if (typeof options.onModalCancel === "function") {
                    options.onModalCancel.call(it.context);
                }
            };
        }
    }, {
        key: "hide",
        value: function hide() {
            this.context.setData({
                isModalShow: false
            });
        }
    } ]);
    return MyModal;
}();

exports.default = MyModal;